package vashion.azeroth.core.api.request;

import com.alibaba.fastjson.JSON;

import lombok.Getter;
import lombok.Setter;
import vashion.azeroth.contant.ErpConstant;
import vashion.azeroth.contant.ErpSignConstants;

public abstract class BaseRequest {

	/**
	 * 系统级参数
	 * 
	 * */

	private @Setter @Getter String appkey;

	private @Setter @Getter String sessionkey;

	private @Setter @Getter String sign;

	public BaseRequest() {

		appkey = ErpConstant.appKey;

		sessionkey = ErpConstant.sessionKey;

	}

	private String toJson() {

		String json = JSON.toJSONString(this);

		return json;
	}

	public String buildJson() {

		String json = toJson();

		String secret = ErpConstant.secret;

		String sign = ErpSignConstants.sign(json, secret);

		this.sign = sign;

		String result = toJson();

		System.out.println("json:" + result);

		return result;

	}

	public abstract Boolean check();

}
